package _1_初级._1_1_数组;

import com.alibaba.fastjson.JSON;

import java.util.ArrayList;
import java.util.List;

public class 面试题_找出数组第二大的数 {

    /**
     * 找出数组中第二大的数，有重复数字
     *
     */

    public static int secondMaxNum(int[] nums){

        int max = 0;
        int secendMax = 0;

        for(int i = 0; i < nums.length; i++){
            if(nums[i] >= max){
                secendMax = max;
                max = nums[i];
            }else if(nums[i] >= secendMax){
                secendMax = nums[i];
            }
        }

        return secendMax;
    }

    public static void main(String[] args) {

        int[] nums = new int[]{2, 3, 1, 0, 2, 5, 3};

        System.out.println(secondMaxNum(nums));
    }

}
